/*
 * @Author: gaojinyu 1593026814@qq.com
 * @Date: 2023-12-07 14:24:09
 * @LastEditors: gaojinyu 1593026814@qq.com
 * @LastEditTime: 2023-12-07 14:45:56
 * @FilePath: \smart-community\src\hooks\useTimes.js
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */
import {ref,onMounted,onUnmounted} from 'vue'
// dayjs
import dayjs from 'dayjs'

export function useTimes(){
  // 当前实时时间
    let nowTimes=ref('')
    let timer = null

    onMounted(()=>{
      timer = setInterval(()=>{
        // dayjs格式化
        nowTimes.value=dayjs().format('YYYY-MM-DD HH:mm:ss')
      },1000)
    })

    onUnmounted(()=>{
        clearInterval(timer)
    })

    return {nowTimes}
}